<h3>Assignments
    <% if logged_in? and (current_user.is_owner?(@task.project) or current_user.is_manager?(@task)) %>
      (<%= link_to 'New Assignment', new_project_task_assignment_path(@task.project, @task) %>)
    <% end %>
</h3>
<table>
  <tr>
    <th>Name</th>
    <th>Description</th>
    <th>Assignee</th>
    <th>Due Date</th>
    <th>Status</th>
    <% if logged_in? and (current_user.is_owner?(@task.project) || current_user.is_manager?(@task)) %>
    <th colspan="2">Administration</th>
    <%end%>
  </tr>

<% @assignments.each do |assig| %>
  <tr>
    <td><%= link_to assig.name, project_task_assignment_path(@task.project_id,@task,assig) %></td>
    <td><%=h assig.desc %></td>
    <td><%= assig.user.present? ? "#{link_to assig.user.name, user_path(assig.user)}" : "#{link_to 'Take', take_project_task_assignment_path(@task.project,@task,assig)}" %></td>
    <td><%=h showtime(assig.due_by) %></td>
    <td>
      <% if assig.is_complete? -%>
        Completed at <%=h showtime(assig.completed_at) %>
        <%= link_to '(undo)', uncomplete_project_task_assignment_path(assig.task.project,assig.task,assig), :confirm => 'Reopen this assignment?' %>
      <% else -%>
        Not completed yet <%= link_to '(complete)', complete_project_task_assignment_path(assig.task.project,assig.task,assig), :confirm => 'Mark this assignment as complete?' %>
      <% end -%>
    </td>
    <% if logged_in? and (current_user.is_owner?(@task.project) || current_user.is_manager?(@task)) %>
    <td><%= link_to 'Edit', edit_project_task_assignment_path(@task.project_id,@task,assig) %></td>
    <td><%= link_to 'Destroy', project_task_assignment_path(@task.project_id,@task,assig), :confirm => 'Are you sure?', :method => :delete %></td>
    <%end%>
  </tr>
<% end %>
</table>